/*
 *  message.h
 *  Untitled
 *
 *  Created by Ben Nolan on 2/11/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#pragma once

#include <vector>
#include <string>
#include "tinyxml/ticpp.h"

namespace Wonderland {

class Message{
public:
	Message(std::vector<char> body) : body_(body){
	}
	Message(std::string body) : body_(body.begin(), body.end()){
	}
	std::vector<char> body() const{
		return body_;
	}
	std::string toString() const{
		std::string st(body_.begin(), body_.end());
		st += "\n";
		return st;
	}

	ticpp::Element* rootElement(){
		return xmlDoc_.FirstChildElement();
	}
	
	bool isXml(){
		try{
			xmlDoc_.Parse(toString().c_str());
		}catch(ticpp::Exception& ex){
			return false;
		}

		return true;
	}
	
private:
	std::vector<char> body_;
	ticpp::Document xmlDoc_;
};

}


